Comparing Skip list

I am currently trying to put together a compare script for DOORS

We use tags within our documents for post processing through RPE

Ex:

<<TAG1234>>

This basically allows us to automate our RPE exports, so for this example the <<TAG###>> works with DOORS absolute numbers 1234 so if the document says something like

"See Section 1.5 for further details" we would replace the 1.5 and it would look like this in DOORS "See Section <<TAG1234>> for further details, this indicates that our post processing macros automatically link in the Word document and fill in the Table of Contents.

 

So what I am doing is putting together a script that pulls the <<TAG###>> and strips it down to its absolute ID and compares them to the absolute ID's within the module to ensure that they still exist and haven't been deleted or the object hasn't been moved.

pragma runLim, 0

Module m = current
Object o

//load view "Standard view"
filtering off

string err
AttrDef adTEMP = find (current Module, "TEMP")

if (exists attribute "TEMP")
 {
  err = delete(adTEMP)
  if (!null err) 
     {
       ack err
     }
  }

create object type "text" attribute "TEMP"

insert (column 2)       
attribute (column 2, "TEMP")
width  (column 2, 130)
title  (column 2, "TAG Code Check")

//=============================================================================
//==================================PROGRAM====================================
//=============================================================================

Skip mySkip = createString

int numAbbr = 0

bool findTAGCodes  (Object o) 
 {  
                
  Regexp searcherRefCodes = regexp "(<<TAG|[0-9]+)[>>]"     

  int i
  int from  = 0

  string cont
  string ss  = null

  bool result = false

  Buffer txt  = create
  txt   = o."Object Text"
                                                                       
  while (search (searcherTAGCodes, txt, from))
   {
          int starter  = start 0
          int offset   = end 1 
                                                                    
          string match  = txt[from + starter  :from +offset]   
           
          ss   = match
         
          o."TEMP"   = o."TEMP"ss"\n"
       
         from += offset + 1

       put(mySkip,match,numAbbr)
     numAbbr++

    }   
   return result
 }

for o in document m do 
 {              
       findTAGCodes (o)                                          
 }

delete (mySkip)

Filter f = contains(attribute "TEMP", ".*", false, true)
set f

filtering on

refresh current Module

I am having trouble though making a skiplist that compares them and filters out any <<TAG##>> that do not match the modules absolute ID

 

My idea is having two skip lists

1. Absolute ID

2. TAG codes

and compare them to each other and show only absolute IDs that do not have a match


MrNiceGuy - Tue Nov 13 18:56:55 EST 2018

Re: Comparing Skip list
Mike.Scharnow - Wed Nov 14 03:55:59 EST 2018

I would probably use two skip lists, one with key = <referenced number> (int), value = doesn't matter, the other one with key = <existing object number> (int), value: doesn't matter.

Like this

 

Regexp searcherTagCodes = regexp "<<TAG([^>]+)>>"

Buffer txt = create()
txt = "lala <<TAG1>> blubb <<TAG3f33>> <<TAG3433>> blo"
int from = 0
Skip mySkip=create()
while (search (searcherTagCodes, txt, from)) {
        int numFrom = from + start 1
        int numTo = from + end 1
        string sMatch = txt [numFrom:numTo]
        print "found " sMatch "..." 
        int iNumber = intOf(sMatch)
        if (iNumber "" != sMatch) {
                print "illegal tag " sMatch "  found in -> " txt " <-\n"
        } else {
                print " is " iNumber ".\n"
                put (mySkip, iNumber, iNumber)
        }
        from = numTo + 1
}


int i
for i in mySkip do { 
        print "->" i "<-"
}
print "\n"


Skip existingObjectNumbers = create()
Object o
Module m = current
for o in entire m do {
        int oNum = o."Absolute Number"
        put (existingObjectNumbers, oNum, oNum)
}
for i in mySkip do {
        if (!find (existingObjectNumbers, i)) {
                print "referenced object " i " not found \n"
        }
}

 

Re: Comparing Skip list
MrNiceGuy - Wed Nov 14 12:09:48 EST 2018

Mike.Scharnow - Wed Nov 14 03:55:59 EST 2018

I would probably use two skip lists, one with key = <referenced number> (int), value = doesn't matter, the other one with key = <existing object number> (int), value: doesn't matter.

Like this

 

Regexp searcherTagCodes = regexp "<<TAG([^>]+)>>"

Buffer txt = create()
txt = "lala <<TAG1>> blubb <<TAG3f33>> <<TAG3433>> blo"
int from = 0
Skip mySkip=create()
while (search (searcherTagCodes, txt, from)) {
        int numFrom = from + start 1
        int numTo = from + end 1
        string sMatch = txt [numFrom:numTo]
        print "found " sMatch "..." 
        int iNumber = intOf(sMatch)
        if (iNumber "" != sMatch) {
                print "illegal tag " sMatch "  found in -> " txt " <-\n"
        } else {
                print " is " iNumber ".\n"
                put (mySkip, iNumber, iNumber)
        }
        from = numTo + 1
}


int i
for i in mySkip do { 
        print "->" i "<-"
}
print "\n"


Skip existingObjectNumbers = create()
Object o
Module m = current
for o in entire m do {
        int oNum = o."Absolute Number"
        put (existingObjectNumbers, oNum, oNum)
}
for i in mySkip do {
        if (!find (existingObjectNumbers, i)) {
                print "referenced object " i " not found \n"
        }
}

 

That's close to what I was thinking except this seems like I would have to type if every variation of <<TAG###>> before hand

 

View before script is run

Absolute ID Object Text TAG Extracted and display number only TAG Exists
1234

Section 3

   
567 Here is some text that will be in the module and will reference Section 3 by having a tag marker like Section <<TAG1234>>. This will also search for markers that do not exists anymore in the module which is found in Section <<TAG2235>>.

1234

2235

Yes

No

8910

This will then filter to display only those objects that have incorrect TAG markers so that we can correct them before RPE export and post processing.

<<TAG9018>>

9018 No

 

View after script is run (Displaying only objects with incorrect TAG markings)

Absolute ID Object Text TAG Extracted and display number only TAG Exists
567 Here is some text that will be in the module and will reference Section 3 by having a tag marker like Section <<TAG1234>>. This will also search for markers that do not exists anymore in the module which is found in Section <<TAG2235>>.

 

2235

 

No

8910

This will then filter to display only those objects that have incorrect TAG markers so that we can correct them before RPE export and post processing.

<<TAG9018>>

9018 No

 

This way might work if there are only a couple of TAG markers but our modules can have hundreds of TAG markers throughout the module.

My script already extracts the absolute number from the object text, I'm just having trouble making skip lists that compare to each other and show what's missing, if that makes any sense.

Re: Comparing Skip list
Mike.Scharnow - Wed Nov 14 12:20:38 EST 2018

MrNiceGuy - Wed Nov 14 12:09:48 EST 2018

That's close to what I was thinking except this seems like I would have to type if every variation of <<TAG###>> before hand

 

View before script is run

Absolute ID Object Text TAG Extracted and display number only TAG Exists
1234

Section 3

   
567 Here is some text that will be in the module and will reference Section 3 by having a tag marker like Section <<TAG1234>>. This will also search for markers that do not exists anymore in the module which is found in Section <<TAG2235>>.

1234

2235

Yes

No

8910

This will then filter to display only those objects that have incorrect TAG markers so that we can correct them before RPE export and post processing.

<<TAG9018>>

9018 No

 

View after script is run (Displaying only objects with incorrect TAG markings)

Absolute ID Object Text TAG Extracted and display number only TAG Exists
567 Here is some text that will be in the module and will reference Section 3 by having a tag marker like Section <<TAG1234>>. This will also search for markers that do not exists anymore in the module which is found in Section <<TAG2235>>.

 

2235

 

No

8910

This will then filter to display only those objects that have incorrect TAG markers so that we can correct them before RPE export and post processing.

<<TAG9018>>

9018 No

 

This way might work if there are only a couple of TAG markers but our modules can have hundreds of TAG markers throughout the module.

My script already extracts the absolute number from the object text, I'm just having trouble making skip lists that compare to each other and show what's missing, if that makes any sense.

Sorry, I do not understand the problem, but perhaps I did not understand your requirement completely.

Perhaps you should create a DXL Attribute.

Your script first creates the skip existingObjectNumbers.

Then you have a loop over every object in the module.

For each object you create a Buffer with the content of o."Object Text", loops through every <<TAG###>> and for each ### that is not included in the exsistingObjectNumbers Skip, adds this information to the DXL attribute.

The code for all this should be deductible from  your and my code snippets. 

 

Edit: Silly me - a DXL attribute is not so good, you would have to create the skip existingObjectNumbers for  each object, that would take too much time. But your approach with the attribute "TEMP" works of course. Instead of "ss" you just add sMatch to the TEMP attribute, if !find (existingObjectNumbers, iNumber).

Re: Comparing Skip list
MrNiceGuy - Mon Nov 26 18:57:36 EST 2018

Mike.Scharnow - Wed Nov 14 12:20:38 EST 2018

Sorry, I do not understand the problem, but perhaps I did not understand your requirement completely.

Perhaps you should create a DXL Attribute.

Your script first creates the skip existingObjectNumbers.

Then you have a loop over every object in the module.

For each object you create a Buffer with the content of o."Object Text", loops through every <<TAG###>> and for each ### that is not included in the exsistingObjectNumbers Skip, adds this information to the DXL attribute.

The code for all this should be deductible from  your and my code snippets. 

 

Edit: Silly me - a DXL attribute is not so good, you would have to create the skip existingObjectNumbers for  each object, that would take too much time. But your approach with the attribute "TEMP" works of course. Instead of "ss" you just add sMatch to the TEMP attribute, if !find (existingObjectNumbers, iNumber).

Im not sure i understand

Why would i add sMatch to the TEMP attribute?

 

Im new to Skip lists still, the only reason i have this so far is trail and error from DXL examples i had.

So trying to do a compare between the two isnt making sense to me at the moment